#include "Player.h"

Player::Player(void)
{
	GameComponent* temp = new Unit();
	my_components.push_back(temp);
	temp = new Unit();
	my_components.push_back(temp);
}

Player::Player(char* fname)
{
	GameComponent* temp;
	int num_units;
	string stemp;
	std::ifstream in (fname);
		if(!in)
		{
			std::cout<<"cannot open file "<< fname << std::endl;
		}
		else
		{
			in >> num_units;
			for(int i = 0; i < num_units; i++)
			{
				in >> stemp;
				temp = new Unit(const_cast<char*>(stemp.c_str()));
				my_components.push_back(temp);
			}
			in.close();
			std::cout << fname << " closed" << std::endl;
		}
}


Player::~Player(void)
{
}


void Player::collectResources()
{
	
}

void Player::addUnit(string fname)
{
	GameComponent* temp = new Unit(const_cast<char*>(fname.c_str()));
	my_components.push_back(temp);
}